package com.lanchetech.dao;

import com.lanchetech.entity.SignIn;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SignInMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(SignIn record);

    int insertSelective(SignIn record);

    SignIn selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(SignIn record);

    int updateByPrimaryKey(SignIn record);

    @Select("select count(id) from sign_in " +
            "where user_id = #{userId} " +
            "and to_days(created_at) = to_days(now())")
    Integer countTodaySignIn(Long userId);

    SignIn findOneByUserIdAndMonthAndDay(@Param("userId") Long userId, @Param("month") Integer month, @Param("day") Integer day);

    Integer countByUserIdAndMonth(@Param("userId") Long userId, @Param("month") Integer month);

    List<SignIn> findAllByUserIdAndMonth(@Param("userId") Long userId, @Param("month") Integer month);



}